<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .box {
            height: 100px;
            width: 100px;
            background-color: red;
        }
        
        .green {
            background-color: green;
        }
        
        .pink {
            height: 100px;
            width: 100px;
            background-color: pink;
        }
    </style>
</head>

<body>
    <div id="app">
        <button @click="fn3">点击</button>
        <div class="pink" v-show="a1"></div>
        <div class="box" v-on:click="fn"></div>
        <!-- <div class="box" v-on:click="fn1"></div> -->
        <div class="box" @click="fn1(111,$event)"></div>
        <div class="pink" v-if="a1"></div>
        <!-- <img height="100px" v-bind:src="book.url"> -->
        <img height="100px" :src="book.url">
        <div :class="a2"></div>

    </div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
            a1: true,
            a2: 'pink',
            book: {
                name: 'H5',
                price: 190,
                url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg2.niutuku.com%2Fdesk%2F1208%2F1300%2Fntk-1300-31979.jpg&refer=http%3A%2F%2Fimg2.niutuku.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1666777119&t=d37746b12beb57a500d0cec690b67499'
            }
        },
        methods: {

            fn3() {
                if (this.a1) {
                    this.a1 = false;
                } else {
                    this.a1 = true;
                }
            },
            fn() {
                console.log("谁点击了我");
                console.log(this.book);
            },
            fn1(e, ele) {
                console.log("谁点击了我11111", e);
                console.log("-----ele-------", ele.target);
                // ele.target.style.backgroundColor = 'green'
                ele.target.classList.add('green')
            }
        }
    })
</script>

</html>